<?php
	include("config.php");
	include("ham.php");
?>
<?php
	$result=mysql_query("SELECT * FROM hoatdong WHERE mahoatdong = 13");
	$row=mysql_fetch_assoc($result);
		$tieude = $row['tieude'];
		$noidung = $row['noidung'];
		$tomtat = $row['tomtat'];
		$hinhanh=$row["hinhanh"];
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" >
	function ham_jjj_3()
	{
		document.getElementById("sss2").style.display="block";
	}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.stylethem {
	color: #000 !important;
	font-weight: bold !important;
	font-size: 24px !important;
}
.stylethem1 {font-weight: bold !important;}
-->
</style>
<script language="JavaScript" type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script language="JavaScript" type="text/javascript" src="ckeditor/sample.js"></script>
<script type="text/javascript" >
	function ham_jjj_3()
	{
		document.getElementById("sss2").style.display="block";
	}
</script>
<script type="text/javascript" >
	function ham_jjj_4()
	{
		document.getElementById("sss3").style.display="block";
	}
</script>
</head>
<body>
<?php
	ini_set('display_errors','0');
	$result=mysql_query("SELECT * FROM hoatdong WHERE mahoatdong = 13");
	$row=mysql_fetch_array($result);
		$tieude = $row['tieude'];
		$id1 = $row['id'];
		$noidung = $row['noidung'];
		$tomtat = $row['tomtat'];
		$ha = $row["hinhanh"];
		$hinhanh=$row["hinhanh"];
		$hinhanh="../images/hoatdong/".$hinhanh;
	
	
?>

    <form action="Untitled-2.php" method="post" enctype="multipart/form-data" name="form1">
      <table width="400" border="0" align="center" cellpadding="3" cellspacing="3">
        
        <tr>
            <td width='20%' style="vertical-align: middle;"><strong>Chỉnh Sửa Ảnh Đã Upload: </strong></td>
            <td width='80%'>
                <span style='cursor:pointer;color:blue;font-size:14px' onclick='ham_jjj_3()'>Chỉnh Sửa</span>
                <div style='overflow:scroll;width:700px;height:200px;display:none;' id='sss2'>
                    <?php
						$truyvan=mysql_query("SELECT * FROM hinhanhhoatdong WHERE mahoatdong = 13");
						$b=1;
						while($ketqua=mysql_fetch_array($truyvan))
						{
							$f=$ketqua["mahinhhoatdong"];
							$a=$ketqua["hinhanh"];
							$a="../images/hoatdong/hinhanhhoatdong13/".$a;
							$c=$ketqua["hinhanh"];
							if($a!=""){
							echo"
                                	<img src='$a' width='100px' height='100px'  /><br /><br />
									<input id='$f' type='file' name='up_hinh_$b' style='margin:3px 0px'>
                            ";
							echo "<select name='xoa_anh_$b' style='margin-left:5px' >";
                                        echo "<option value='khong' >";
                                            echo "Tùy chọn";
                                        echo "</option>";
                                        echo "<option value='co' >";
                                            echo "Xóa ảnh";
                                        echo "</option>";
                                    echo "</select>";
                                    echo "<input type='hidden' name='hd_up_hinh_$b' value='$c'/>";
                                    echo "<br><br><br><hr><br><br>";}
							else
							echo "<p style='color:white'>chưa có hình ảnh</p>";
							$b++;
						}
                    ?>
                </div>
            </td>
        </tr>
        <tr>
            <td width='20%' style="vertical-align: middle;"><strong>Up Thêm Ảnh: </strong></td>
            <td width='80%'>
                <span style='cursor:pointer;color:blue;font-size:14px' onclick='ham_jjj_4()'>Up Load Ảnh</span>
                <div style='overflow:scroll;width:700px;height:200px;display:none;' id='sss3'>
                    <?php
                        for($i=1;$i<=1000;$i++)
                        {
                            echo"
                                
                                    <input type='file' name='up_load_hinh_$i' style='margin:3px 0px'><br>
                            ";
                        }
                    ?>
                </div>
            </td>
        </tr>
        
        <tr align="center" bgcolor="#CFCFCF">
        	<td width='20%'>&nbsp;</td>
			<td width='80%'><input type="submit" class="nut_chapnhan" value="Chấp nhận" name="them"></td>
        </tr>  
      </table>
    </form>
</body>
</html>
<?php
	
	if(isset($_POST["them"]))
	{
		$truyvan5=mysql_query("SELECT * FROM hinhanhhoatdong WHERE mahoatdong = 13");
		$k=1;
		$thu_muc="../images/hoatdong/hinhanhhoatdong13/";
		while($ketqua5=mysql_fetch_array($truyvan5))
		{
			$c=$_POST['hd_up_hinh_'.$k];
			$d= $_POST['xoa_anh_'.$k];
			$h = $_FILES["up_hinh_".$k]["name"];
			if($d == "co")
			$truyvan7 = mysql_query("DELETE FROM `hinhanhhoatdong` WHERE `mahoatdong` = '13' and `hinhanh` = '$c'");
			if($d == "khong")
			{
				if ($h != "")
				{
					chong_90($h);
					$truyvan6 = mysql_query("UPDATE `hinhanhhoatdong` SET `hinhanh` = '$h' WHERE `mahoatdong` = '13' and `hinhanh` = '$c'");
				}
			}
			
			echo $h;
			$k++;
		}		
	}
?>